home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archivers / XpkDisk / device1.a < prev    next >
Text File  |  1996-09-26  |  4KB  |  217 lines

  1. ; DEVICE1.A
  2. ; $Id: device1.a,v 1.5 1995/04/12 00:14:43 Rhialto Exp $
  3. ; $Log: device1.a,v $
  4. ; Revision 1.5  1995/04/12  00:14:43  Rhialto
  5. ; Move Id back so it is still recognised as a device.
  6. ;
  7. ; Revision 1.4  1995/04/08  20:23:48  Rhialto
  8. ; Add/correct version strings.
  9. ;
  10. ; Revision 1.3  1993/11/08  13:11:15  Rhialto
  11. ; Add RCS tags.
  12. ;
  13.         include    "c.i"
  14. ;;;;
  15. ;
  16. ;   Some constants that need to be modified on specific versions
  17.  
  18. RTPRI        equ     0
  19.  
  20. ;;;;
  21. ;
  22. ; The first executable location. This should return an error in case
  23. ; someone tried to run you as a program (instead of loading you as a
  24. ; device)
  25.  
  26.     section text,code
  27.  
  28.     moveq.l #20,d0
  29.     rts
  30.  
  31. ;;;;
  32. ;
  33. ; A romtag structure. Both "exec" and "ramlib" look for this structure to
  34. ; discover magic constants about you (such as where to start running you
  35. ; from...).
  36. ;
  37.     xref    _DevName
  38.     xref    _idString
  39.     xdef    _RomTag
  40. _RomTag:
  41.     dc.w    RTC_MATCHWORD
  42.     dc.l    _RomTag     ; rt_MatchTag
  43.     dc.l    EndCode     ; rt_EndSkip
  44.     dc.b    RTF_AUTOINIT    ; rt_Flags
  45.     dc.b    VERSION     ; rt_Version
  46.     dc.b    NT_DEVICE    ; rt_Type
  47.     dc.b    RTPRI        ; rt_Pri
  48.     dc.l    _DevName    ; rt_Name
  49.     dc.l    _idString    ; rt_IdString
  50.     dc.l    Init        ; rt_Init
  51.  
  52.     xref    _InitTable
  53.     xref    @Init
  54. Init:
  55.     dc.l    xd_SIZEOF    ; size of data portion of Device
  56.     dc.l    LibVectors    ; pointer to function initialisers
  57.     dc.l    InitTable    ; pointer to data initialisers
  58.     dc.l    @Init        ; routine to run (d0: dev ptr, a0: seglist)
  59.  
  60.     xref     @DevOpen,@DevClose,@DevExpunge
  61.     xref     @DevBeginIO
  62.     xref     @DevAbortIO
  63. LibVectors:
  64.     dc.l    @DevOpen,@DevClose,@DevExpunge,LibNull
  65.     dc.l    @DevBeginIO
  66.     dc.l    @DevAbortIO
  67.     dc.l    -1
  68.  
  69. INITBYTE    MACRO    ; &offset,&value
  70.         IFLE    (\1)-255        ;If offset <=255
  71.         DC.B    $a0,\1        ;use byte offset
  72.         DC.B    \2,0
  73.         MEXIT            ;exit early
  74.         ENDC
  75.         DC.B    $e0,0
  76.         DC.W    \1
  77.         DC.B    \2,0
  78.         ENDM
  79.  
  80. INITWORD    MACRO    ; &offset,&value
  81.         IFLE    (\1)-255        ;If offset <=255
  82.         DC.B    $90,\1        ;use byte offset
  83.         DC.W    \2
  84.         MEXIT            ;exit early
  85.         ENDC
  86.         DC.B    $d0,0
  87.         DC.W    \1
  88.         DC.W    \2
  89.         ENDM
  90.  
  91. INITLONG    MACRO    ; &offset,&value
  92.         IFLE    (\1)-255        ;If offset <=255
  93.         DC.B    $80,\1        ;use byte offset
  94.         DC.L    \2
  95.         MEXIT            ;exit early
  96.         ENDC
  97.         DC.B    $c0,0
  98.         DC.W    \1
  99.         DC.L    \2
  100.         ENDM
  101.  
  102. InitTable:
  103.     INITBYTE ln_Type,NT_DEVICE
  104.     INITLONG ln_Name,_DevName
  105.     INITBYTE dev_Flags,LIBF_CHANGED!LIBF_SUMUSED,
  106.     INITWORD dev_Version,VERSION
  107.     INITWORD dev_Revision,REVISION
  108.     INITLONG dev_IdString,_idString
  109.     dc.w    0
  110.  
  111.     dc.b    "$Id: device1.a,v 1.5 1995/04/12 00:14:43 Rhialto Exp $",0
  112.  
  113. ;;;;
  114. ;
  115. ; Here begin the system interface commands. When the user calls
  116. ; OpenDevice/CloseDevice/RemDevice, this eventually gets trahslated into
  117. ; a call to the following routines (Open/Close/Expunge).  Exec has
  118. ; already put our device pointer in A6 for us.    Exec has turned off task
  119. ; switching while in these routines (via Forbid/Permit), so we should not
  120. ; take too long in them.
  121. ;
  122. ; These glue routines are not necessary when using the special
  123. ; __D0 keywords of DICE. When we do use these, don't forget to make sure
  124. ; the C routines expect the arguments on the stack (i.e. __stkargs)
  125.  
  126.     ifne    0
  127.     xdef    Init
  128.     xref    _Init
  129. Init:                ;a0=segment list
  130.     move.l    A0,-(sp)
  131.     jsr    _Init
  132.     addq    #4,sp
  133.     rts
  134.  
  135.     xdef    DevOpen
  136.     xref    _DevOpen
  137. DevOpen:            ;d0=unitnum,d1=flags,a1=ioreq,a6=device
  138.     movem.l D0-D1/A1/A6,-(sp)
  139.     jsr    _DevOpen
  140.     lea    16(sp),sp
  141.     rts
  142.  
  143.     xdef    DevClose
  144.     xref    _DevClose
  145. DevClose:            ;a1=ioreq,a6=device
  146.     movem.l A1/A6,-(sp)
  147.     jsr    _DevClose
  148.     addq    #8,sp
  149.     rts
  150.  
  151.     xdef    DevExpunge
  152.     xref    _DevExpunge
  153. DevExpunge:            ;a6=device
  154.     movem.l A6,-(sp)
  155.     jsr    _DevExpunge
  156.     addq    #4,sp
  157.     rts
  158.  
  159.     xdef    DevBeginIO
  160.     xref    _DevBeginIO
  161. DevBeginIO:            ;a1=ioreq,a6=device
  162.     movem.l A1/A6,-(sp)
  163.     jsr    _DevBeginIO
  164.     addq    #8,sp
  165.     rts
  166.  
  167.     xdef    DevAbortIO
  168.     xref    _DevAbortIO
  169. DevAbortIO:            ;a1=ioreq,a6=device
  170.     movem.l A1/A6,-(sp)
  171.     jsr    _DevAbortIO
  172.     addq    #8,sp
  173.     rts
  174.     endc
  175.  
  176. LibNull:
  177.     clr.l    d0
  178.     rts
  179.  
  180.  
  181. ;;;;
  182. ;
  183.     xdef    @UnitSeglist,_UnitSeglist
  184.     xref    @UnitTask,_UnitTask
  185.     ds.l    0
  186.     nop            ; fake segment length
  187.     nop
  188. @UnitSeglist:
  189. _UnitSeglist:
  190.     nop            ; pointer to next segment
  191.     nop
  192.     nop            ; extra padding just in case
  193.     nop
  194.     jmp    _UnitTask(pc)
  195.  
  196.     ifne    HANDLE_IO_QUICK
  197. ;;;;
  198. ;
  199. ;   C interface to the atomic set bit and test old value instruction.
  200. ;
  201. ;   Called as    BSET_ACTIVE(byte *address).
  202. ;
  203. ;   Old value of the bit returned all over d0.w
  204.  
  205.     xdef    _BSET_ACTIVE
  206.     xdef    @BSET_ACTIVE
  207. _BSET_ACTIVE:
  208.     move.l    4(sp),a0
  209. @BSET_ACTIVE:
  210.     bset    #UNITB_ACTIVE,(a0)         ; 0 UNITB_ACTIVE
  211.     sne    d0
  212.     rts
  213.     endc    ; HANDLE_IO_QUICK
  214.  
  215. EndCode
  216.     end
  217.